import { legacy_createStore } from 'redux'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

import reducer from './combine'

// blacklist--不参与缓存
// whitelist--参与缓存
const persistConfig = {
  key: 'root',
  storage,
  whitelist: ['persist']
  // blacklist
}

const initReducer = persistReducer(persistConfig, reducer)
const store = legacy_createStore(initReducer)
const persistor = persistStore(store)

export {
  store,
  persistor
}
